﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;

namespace Itech_Run.Domain.Shared.Base
{
    public class CustomAggregateRoot<TKey> : BasicAggregateRoot<TKey>
    {
        [Required]
        [StringLength(36)]
        public new virtual TKey Id { get; set; }
        [StringLength(36)]
        public virtual string? CreatedBy { get; set; }
        [Column(TypeName = "dateTime")]
        public virtual DateTime? CreatedTime { get; set; }
        [StringLength(36)]
        public virtual string? LastModifiedBy { get; set; }
        [Column(TypeName = "dateTime")]
        public virtual DateTime? LastModifiedTime { get; set; }

        public CustomAggregateRoot()
        {
            if (typeof(TKey) == typeof(string))
            {
                this.Id = (TKey)Convert.ChangeType(Guid.NewGuid().ToString(), typeof(TKey));
            }
        }
        public CustomAggregateRoot(TKey id)
        {
            this.Id = id;
        }

    }
}
